home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / calvinintro.lha / MAHONEY&KAKTUS < prev    next >
Encoding:
Text File  |  1989-12-25  |  6.7 KB  |  453 lines

  1.  
  2. ** THIS IS THE PLAY ROUTINE FOR THE MUSIC - BY HALLONSOFT **
  3.  
  4. GEN_INIT:
  5.     jsr    mt_init
  6.     move.l    $6c,osjmp+2
  7.     move.l    #newvbi,$6c
  8.     ;insert prog here
  9. AU_REVOIR:
  10.     ;last prog run
  11.     jsr    mt_end
  12.     move.l    osjmp+2,$6c
  13.     rts
  14.  
  15. mt_init:lea    mt_data,a0
  16.     add.l    #$03b8,a0
  17.     moveq    #$7f,d0
  18.     moveq    #0,d1
  19. mt_init1:
  20.     move.l    d1,d2
  21.     subq.w    #1,d0
  22. mt_init2:
  23.     move.b    (a0)+,d1
  24.     cmp.b    d2,d1
  25.     bgt.s    mt_init1
  26.     dbf    d0,mt_init2
  27.     addq.b    #1,d2
  28.  
  29. mt_init3:
  30.     lea    mt_data,a0
  31.     lea    mt_sample1(pc),a1
  32.     asl.l    #8,d2
  33.     asl.l    #2,d2
  34.     add.l    #$438,d2
  35.     add.l    a0,d2
  36.     moveq    #$1e,d0
  37. mt_init4:
  38.     move.l    d2,(a1)+
  39.     moveq    #0,d1
  40.     move.w    42(a0),d1
  41.     asl.l    #1,d1
  42.     add.l    d1,d2
  43.     add.l    #$1e,a0
  44.     dbf    d0,mt_init4
  45.  
  46.     lea    mt_sample1(PC),a0
  47.     moveq    #0,d0
  48. mt_clear:
  49.     move.l    (a0,d0.w),a1
  50.     clr.l    (a1)
  51.     addq.w    #4,d0
  52.     cmp.w    #$7c,d0
  53.     bne.s    mt_clear
  54.  
  55.     clr.w    $dff0a8
  56.     clr.w    $dff0b8
  57.     clr.w    $dff0c8
  58.     clr.w    $dff0d8
  59.     clr.l    mt_partnrplay
  60.     clr.l    mt_partnote
  61.     clr.l    mt_partpoint
  62.  
  63.     move.b    mt_data+$3b6,mt_maxpart+1
  64.     rts
  65.  
  66. ; call 'mt_end' to switch the sound off
  67.  
  68. mt_end:    clr.w    $dff0a8
  69.     clr.w    $dff0b8
  70.     clr.w    $dff0c8
  71.     clr.w    $dff0d8
  72.     move.w    #$f,$dff096
  73.     rts
  74.  
  75. ; the playroutine - call this every frame
  76. newvbi:        movem    d0-d7/a0-a6,-(a7)
  77.         jsr    mt_music
  78. osjmp:        jmp    0
  79. mt_music:
  80.     addq.w    #1,mt_counter
  81. mt_cool:cmp.w    #6,mt_counter
  82.     bne.s    mt_notsix
  83.     clr.w    mt_counter
  84.     bra    mt_rout2
  85.  
  86. mt_notsix:
  87.     lea    mt_aud1temp(PC),a6
  88.     tst.b    3(a6)
  89.     beq.s    mt_arp1
  90.     lea    $dff0a0,a5        
  91.     bsr.s    mt_arprout
  92. mt_arp1:lea    mt_aud2temp(PC),a6
  93.     tst.b    3(a6)
  94.     beq.s    mt_arp2
  95.     lea    $dff0b0,a5
  96.     bsr.s    mt_arprout
  97. mt_arp2:lea    mt_aud3temp(PC),a6
  98.     tst.b    3(a6)
  99.     beq.s    mt_arp3
  100.     lea    $dff0c0,a5
  101.     bsr.s    mt_arprout
  102. mt_arp3:lea    mt_aud4temp(PC),a6
  103.     tst.b    3(a6)
  104.     beq.s    mt_arp4
  105.     lea    $dff0d0,a5
  106.     bra.s    mt_arprout
  107. mt_arp4:rts
  108.  
  109. mt_arprout:
  110.     move.b    2(a6),d0
  111.     and.b    #$0f,d0
  112.     tst.b    d0
  113.     beq    mt_arpegrt
  114.     cmp.b    #$01,d0
  115.     beq.s    mt_portup
  116.     cmp.b    #$02,d0
  117.     beq.s    mt_portdwn
  118.     cmp.b    #$0a,d0
  119.     beq.s    mt_volslide
  120.     rts
  121.  
  122. mt_portup:
  123.     moveq    #0,d0
  124.     move.b    3(a6),d0
  125.     sub.w    d0,22(a6)
  126.     cmp.w    #$71,22(a6)
  127.     bpl.s    mt_ok1
  128.     move.w    #$71,22(a6)
  129. mt_ok1:    move.w    22(a6),6(a5)
  130.     rts
  131.  
  132. mt_portdwn:
  133.     moveq    #0,d0
  134.     move.b    3(a6),d0
  135.     add.w    d0,22(a6)
  136.     cmp.w    #$538,22(a6)
  137.     bmi.s    mt_ok2
  138.     move.w    #$538,22(a6)
  139. mt_ok2:    move.w    22(a6),6(a5)
  140.     rts
  141.  
  142. mt_volslide:
  143.     moveq    #0,d0
  144.     move.b    3(a6),d0
  145.     lsr.b    #4,d0
  146.     tst.b    d0
  147.     beq.s    mt_voldwn
  148.     add.w    d0,18(a6)
  149.     cmp.w    #64,18(a6)
  150.     bmi.s    mt_ok3
  151.     move.w    #64,18(a6)
  152. mt_ok3:    move.w    18(a6),8(a5)
  153.     rts
  154. mt_voldwn:
  155.     moveq    #0,d0
  156.     move.b    3(a6),d0
  157.     and.b    #$0f,d0
  158.     sub.w    d0,18(a6)
  159.     bpl.s    mt_ok4
  160.     clr.w    18(a6)
  161. mt_ok4:    move.w    18(a6),8(a5)
  162.     rts
  163.  
  164. mt_arpegrt:
  165.     move.w    mt_counter(PC),d0
  166.     cmp.w    #1,d0
  167.     beq.s    mt_loop2
  168.     cmp.w    #2,d0
  169.     beq.s    mt_loop3
  170.     cmp.w    #3,d0
  171.     beq.s    mt_loop4
  172.     cmp.w    #4,d0
  173.     beq.s    mt_loop2
  174.     cmp.w    #5,d0
  175.     beq.s    mt_loop3
  176.     rts
  177.  
  178. mt_loop2:
  179.     moveq    #0,d0
  180.     move.b    3(a6),d0
  181.     lsr.b    #4,d0
  182.     bra.s    mt_cont
  183. mt_loop3:
  184.     moveq    #$00,d0
  185.     move.b    3(a6),d0
  186.     and.b    #$0f,d0
  187.     bra.s    mt_cont
  188. mt_loop4:
  189.     move.w    16(a6),d2
  190.     bra.s    mt_endpart
  191. mt_cont:
  192.     add.w    d0,d0
  193.     moveq    #0,d1
  194.     move.w    16(a6),d1
  195.     and.w    #$fff,d1
  196.     lea    mt_arpeggio(PC),a0
  197. mt_loop5:
  198.     move.w    (a0,d0),d2
  199.     cmp.w    (a0),d1
  200.     beq.s    mt_endpart
  201.     addq.l    #2,a0
  202.     bra.s    mt_loop5
  203. mt_endpart:
  204.     move.w    d2,6(a5)
  205.     rts
  206.  
  207. mt_rout2:
  208.     lea    mt_data,a0
  209.     move.l    a0,a3
  210.     add.l    #$0c,a3
  211.     move.l    a0,a2
  212.     add.l    #$3b8,a2
  213.     add.l    #$43c,a0
  214.     move.l    mt_partnrplay(PC),d0
  215.     moveq    #0,d1
  216.     move.b    (a2,d0),d1
  217.     asl.l    #8,d1
  218.     asl.l    #2,d1
  219.     add.l    mt_partnote(PC),d1
  220.     move.l    d1,mt_partpoint
  221.     clr.w    mt_dmacon
  222.  
  223.     lea    $dff0a0,a5
  224.     lea    mt_aud1temp(PC),a6
  225.     bsr    mt_playit
  226.     lea    $dff0b0,a5
  227.     lea    mt_aud2temp(PC),a6
  228.     bsr    mt_playit
  229.     lea    $dff0c0,a5
  230.     lea    mt_aud3temp(PC),a6
  231.     bsr    mt_playit
  232.     lea    $dff0d0,a5
  233.     lea    mt_aud4temp(PC),a6
  234.     bsr    mt_playit
  235.     move.w    #$01f4,d0
  236. mt_rls:    dbf    d0,mt_rls
  237.  
  238.     move.w    #$8000,d0
  239.     or.w    mt_dmacon,d0
  240.     move.w    d0,$dff096
  241.  
  242.     lea    mt_aud4temp(PC),a6
  243.     cmp.w    #1,14(a6)
  244.     bne.s    mt_voice3
  245.     move.l    10(a6),$dff0d0
  246.  
  247.  
  248.  
  249.  
  250.     move.w    #1,$dff0d4
  251. mt_voice3:
  252.     lea    mt_aud3temp(PC),a6
  253.     cmp.w    #1,14(a6)
  254.     bne.s    mt_voice2
  255.     move.l    10(a6),$dff0c0
  256.  
  257.  
  258.  
  259.  
  260.     move.w    #1,$dff0c4
  261. mt_voice2:
  262.     lea    mt_aud2temp(PC),a6
  263.     cmp.w    #1,14(a6)
  264.     bne.s    mt_voice1
  265.     move.l    10(a6),$dff0b0
  266.  
  267.  
  268.  
  269.  
  270.     move.w    #1,$dff0b4
  271. mt_voice1:
  272.     lea    mt_aud1temp(PC),a6
  273.     cmp.w    #1,14(a6)
  274.     bne.s    mt_voice0
  275.     move.l    10(a6),$dff0a0
  276.  
  277.  
  278.  
  279.  
  280.     move.w    #1,$dff0a4
  281. mt_voice0:
  282.     move.l    mt_partnote(PC),d0
  283.     add.l    #$10,d0
  284.     move.l    d0,mt_partnote
  285.     cmp.l    #$400,d0
  286.     bne.s    mt_stop
  287. mt_higher:
  288.     clr.l    mt_partnote
  289.     addq.l    #1,mt_partnrplay
  290.     moveq    #0,d0
  291.     move.w    mt_maxpart(PC),d0
  292.     move.l    mt_partnrplay(PC),d1
  293.     cmp.l    d0,d1
  294.     bne.s    mt_stop
  295.     clr.l    mt_partnrplay
  296. ;    st    Pflag
  297. mt_stop:tst.w    mt_status
  298.     beq.s    mt_stop2
  299.     clr.w    mt_status
  300.     bra.s    mt_higher
  301. mt_stop2:
  302.     rts
  303.  
  304. mt_playit:
  305.     move.l    (a0,d1.l),(a6)
  306.     addq.l    #4,d1
  307.     moveq    #0,d2
  308.     move.b    2(a6),d2
  309.     and.b    #$f0,d2
  310.     lsr.b    #4,d2
  311.  
  312.     move.b    (a6),d0
  313.     and.b    #$f0,d0
  314.     or.b    d0,d2
  315.     tst.b    d2
  316.     beq.s    mt_nosamplechange
  317.  
  318.     moveq    #0,d3
  319.     lea    mt_samples(PC),a1
  320.     move.l    d2,d4
  321.     asl.l    #2,d2
  322.     mulu    #$1e,d4
  323.     move.l    (a1,d2),4(a6)
  324.     move.w    (a3,d4.l),8(a6)
  325.     move.w    2(a3,d4.l),18(a6)
  326.     move.w    4(a3,d4.l),d3
  327.     tst.w    d3
  328.     beq.s    mt_displace
  329.     move.l    4(a6),d2
  330.     add.l    d3,d2
  331.     move.l    d2,4(a6)
  332.     move.l    d2,10(a6)
  333.     move.w    6(a3,d4.l),8(a6)
  334.     move.w    6(a3,d4.l),14(a6)
  335.     move.w    18(a6),8(a5)
  336.     bra.s    mt_nosamplechange
  337.  
  338. mt_displace:
  339.     move.l    4(a6),d2
  340.     add.l    d3,d2
  341.     move.l    d2,10(a6)
  342.     move.w    6(a3,d4.l),14(a6)
  343.     move.w    18(a6),8(a5)
  344. mt_nosamplechange:
  345.     move.w    (a6),d0
  346.     and.w    #$fff,d0
  347.     tst.w    d0
  348.     beq.s    mt_retrout
  349.     move.w    (a6),16(a6)
  350.     move.w    20(a6),$dff096
  351.     move.l    4(a6),(a5)
  352.     move.w    8(a6),4(a5)
  353.     move.w    (a6),d0
  354.     and.w    #$fff,d0
  355.     move.w    d0,6(a5)
  356.     move.w    20(a6),d0
  357.     or.w    d0,mt_dmacon
  358.  
  359. mt_retrout:
  360.     tst.w    (a6)
  361.     beq.s    mt_nonewper
  362.     move.w    (a6),22(a6)
  363.  
  364. mt_nonewper:
  365.     move.b    2(a6),d0
  366.     and.b    #$0f,d0
  367.     cmp.b    #$0b,d0
  368.     beq.s    mt_posjmp
  369.     cmp.b    #$0c,d0
  370.     beq.s    mt_setvol
  371.     cmp.b    #$0d,d0
  372.     beq.s    mt_break
  373.     cmp.b    #$0e,d0
  374.     beq.s    mt_setfil
  375.     cmp.b    #$0f,d0
  376.     beq.s    mt_setspeed
  377.     rts
  378.  
  379. mt_posjmp:
  380.     not.w    mt_status
  381.     moveq    #0,d0
  382.     move.b    3(a6),d0
  383.     subq.b    #1,d0
  384.     move.l    d0,mt_partnrplay
  385.     rts
  386.  
  387. mt_setvol:
  388.     move.b    3(a6),8(a5)
  389.     rts
  390.  
  391. mt_break:
  392.     not.w    mt_status
  393.     rts
  394.  
  395. mt_setfil:
  396.     moveq    #0,d0
  397.     move.b    3(a6),d0
  398.     and.b    #1,d0
  399.     rol.b    #1,d0
  400.     and.b    #$fd,$bfe001
  401.     or.b    d0,$bfe001
  402.     rts
  403.  
  404. mt_setspeed:
  405.     move.b    3(a6),d0
  406.     and.b    #$0f,d0
  407.     beq.s    mt_back
  408.     clr.w    mt_counter
  409.     move.b    d0,mt_cool+3
  410. mt_back:rts
  411.  
  412. mt_aud1temp:
  413.     dcb.w    10,0
  414.     dc.w    1
  415.     dcb.w    2,0
  416. mt_aud2temp:
  417.     dcb.w    10,0
  418.     dc.w    2
  419.     dcb.w    2,0
  420. mt_aud3temp:
  421.     dcb.w    10,0
  422.     dc.w    4
  423.     dcb.w    2,0
  424. mt_aud4temp:
  425.     dcb.w    10,0
  426.     dc.w    8
  427.     dcb.w    2,0
  428.  
  429. mt_partnote:    dc.l    0
  430. mt_partnrplay:    dc.l    0
  431. mt_counter:    dc.w    0
  432. mt_partpoint:    dc.l    0
  433. mt_samples:    dc.l    0
  434. mt_sample1:    dcb.l    31,0
  435. mt_maxpart:    dc.w    0
  436. mt_dmacon:    dc.w    0
  437. mt_status:    dc.w    0
  438.  
  439. mt_arpeggio:
  440.     dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
  441.     dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
  442.     dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
  443.     dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
  444.     dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
  445.  
  446.  
  447. notetable:    dc.w    856,808,762,720,678,640,604,570
  448.         dc.w    538,508,480,453,428,404,381,360
  449.         dc.w    339,320,302,285,269,254,240,226  
  450.         dc.w    214,202,190,180,170,160,151,143
  451.         dc.w    135,127,120,113,000
  452.     EVEN
  453.